package fr.ensai.tp1.model;


import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.apache.commons.lang3.builder.ToStringBuilder;


@Entity
@DiscriminatorValue("conducteur")
public class Conducteur extends Passager {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4911678993845850351L;
	
	@OneToOne(cascade = CascadeType.ALL)
	private PermisDeConduire permis;
	
	@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.LAZY)
	private List<Vehicule> vehicules = new ArrayList<Vehicule>();
	
	
	public void addVehicule(Vehicule v){
		this.vehicules.add(v);
	}
	
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
	

	public List<Vehicule> getVehicules() {
		return vehicules;
	}
	
	public void setVehicules(List<Vehicule> vehicules) {
		this.vehicules = vehicules;
	}

	public PermisDeConduire getPermis() {
		return permis;
	}

	public void setPermis(PermisDeConduire permis) {
		this.permis = permis;
	}
}
